package com.cl.short_video_java.menum;

/**
 * @Author 付
 * @Date 2024-11-02 9:35
 * @Version 1.0
 * @description 操作消息枚举
 * @since 1.0
 */
public enum MessageType {
	OPER_ERROR("操作失败", 400),
	OPER_SUCCESS("操作成功", 200),


	UPDATE_SUCCESS("修改成功", 200),
	UPDATE_ERROR("修改失败", 400),

	INSERT_SUCCESS("新增成功", 200),
	INSERT_ERROR("新增失败", 400),

	DELETE_SUCCESS("删除成功", 200),
	DELETE_ERROR("删除失败", 400),

	COMMON_SUCCESS("可以了", 200),
	COMMON_ERROR("失败了", 400),

	NOT_FOUND("未找到相关资源", 404);

	private final String message;
	private final int code;

	MessageType(String message, int code) {
		this.message = message;
		this.code = code;
	}

	public String getMessage() {
		return message;
	}

	public int getCode() {
		return code;
	}

	public static MessageType fromString(String value) {
		for (MessageType errorEnum : MessageType.values()) {
			if (errorEnum.name().equals(value)) {
				return errorEnum;
			}
		}
		throw new IllegalArgumentException("无效的输入值: " + value);
	}
}
